package com.hwy.catering.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hwy.catering.entity.Flavor;
import com.hwy.catering.mapper.FlavorMapper;
import com.hwy.catering.service.FlavorService;
import com.hwy.catering.utils.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Service
public class FlavorServiceImpl extends ServiceImpl<FlavorMapper,Flavor> implements FlavorService {

    @Resource
    private FlavorMapper flavorMapper;


    @Override
    public R findFlavor() {
        HashMap<Object, Object> flavorMap = new HashMap<>();
        ArrayList<String> idList = new ArrayList<>();
        List<Flavor> flavors = flavorMapper.selectList(null);
        for (Flavor flavor: flavors){
            idList.add(flavor.getId().toString());
        }
        flavorMap.put("flavorList",flavors);
        flavorMap.put("idList",idList);
        return R.success(flavorMap);
    }
}
